/*
 * Semantico.h
 *
 *  Created on: 21/10/2008
 *      Author: Thiago A. L. Genez
 *              Pedro Sanches Junior
 */

#ifndef SEMANTICO_H_
#define SEMANTICO_H_

#include "../Sintatico/Tree.h"
#include "../Sintatico/TabelaHash.h"
#include "../Sintatico/ProcedimentoFuncao.h"
#include "../Sintatico/Variavel.h"
#include "../Sintatico/Parametro.h"
#include "TokenizerExpression.h"
#include <vector>

class Semantico {
public:
	Semantico();

	bool semanticAnalysis(TabelaHash*, Tree*, noTree*);

	virtual ~Semantico();

private:

	bool checkFunctionDeclaration(noTree*);
	bool checkVariableDeclaration(noTree*);
	bool checkVariableDeclarationUsed(noTree*);
	bool goFunctionProcedure(noTree *);
	bool goVariable(noTree *);
	bool goCommands(noTree *);
	bool isNumber(string);
	bool isSymbol(string);
	bool isBoolean(string);
	string lookingForProcedure(string,noTree*);
	bool validateExpression(list<string>*,noTree*,string&);
	bool callFunction(vector<TokenizerExpression>&);
	bool doOperations(vector<TokenizerExpression>&);
	void solveComparation(vector<TokenizerExpression>&);
	void solveOrAnd(vector<TokenizerExpression>&);
	void removeParenteses(vector<TokenizerExpression>&);
	bool variableDeclared(noTree*,string);
	bool isOperadorBooleanoToInteger(string);
	bool isOperadorIntegerToInteger(string);
	bool isOperadorBooleanoToBooleano(string);

	TabelaHash *tabelaHash;
	Tree *treeSemantic;
	noTree *errorNode;
};

#endif /* SEMANTICO_H_ */
